package com.touch.app.common.config;

import com.touch.app.common.filter.ApiFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.servlet.Filter;
import java.util.ArrayList;
import java.util.List;

@Configuration
public class FilterConfig {

    @Bean
    public FilterRegistrationBean<Filter> apiFilter() {
        List<String> patternsList = new ArrayList<>();
        patternsList.add("/*");
        FilterRegistrationBean<Filter> registrationBean = new FilterRegistrationBean<>();
        registrationBean.setFilter(new ApiFilter());
        registrationBean.setUrlPatterns(patternsList);
        registrationBean.setOrder(1);
        return registrationBean;
    }
}

